<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title></title>
  <!-- 依 赖 样 式 -->
  <link rel="stylesheet" href="component/pear/css/pear.css" />
  <!-- 加 载 样 式 -->
  <link rel="stylesheet" href="admin/css/loader.css" />
  <!-- 布 局 样 式 -->
  <link rel="stylesheet" href="admin/css/admin.css" />
  <link rel="stylesheet" href="component/elementUI/index.css">
</head>
<!-- 结 构 代 码 -->

<body class="layui-layout-body pear-admin">
  <!-- 布 局 框 架 -->
  <div id="app" class="layui-layout layui-layout-admin">
    <!-- 顶 部 样 式 -->
    <div class="layui-header">
      <!-- 菜 单 顶 部 -->
      <div class="layui-logo">
        <!-- 图 标 -->
        <img class="logo" />
        <!-- 标 题 -->
        <span class="title"></span>
      </div>
      <!-- 顶 部 左 侧 功 能 -->
      <ul class="layui-nav layui-layout-left">
        <li class="collapse layui-nav-item">
          <a href="#" class="layui-icon layui-icon-shrink-right"></a>
        </li>
        <li class="refresh layui-nav-item">
          <a href="#" class="layui-icon layui-icon-refresh-1" loading="600"></a>
        </li>
      </ul>
      <!-- 多 系 统 菜 单 -->
      <div id="control" class="layui-layout-control"></div>
      <!-- 顶 部 右 侧 菜 单 -->
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item layui-hide-xs">
          <a href="#" class="menuSearch layui-icon layui-icon-search"></a>
        </li>
        <li class="layui-nav-item layui-hide-xs">
          <a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a>
        </li>
        <li class="layui-nav-item layui-hide-xs">
          <a href="https://marketing.ediblefungus.cn/dist/h5XKLJ/index.html#/"
            class="layui-icon layui-icon-website"></a>
        </li>
        <!-- <li class="layui-nav-item layui-hide-xs message"></li> -->
        <li class="layui-nav-item user">
          <!-- 头 像 -->
          <a class="layui-icon layui-icon-username" href="javascript:;"></a>
          <!-- 功 能 菜 单 -->
          <dl class="layui-nav-child">
            <dd>
              <a user-menu-url="./view/System/Person/Person1.html" user-menu-id="5555" user-menu-title="基本资料">基本资料</a>
            </dd>
            <dd>
              <a user-menu-url="./view/System/Changepassword/Changepassword.html" user-menu-id="6666"
                user-menu-title="修改密码">修改密码</a>
            </dd>
            <dd><a href="javascript:void(0);" @click="handleCance">注销企业</a></dd>
            <dd><a href="javascript:void(0);" class="logout">注销登录</a></dd>
          </dl>
        </li>
        <!-- 主 题 配 置 -->
        <li class="layui-nav-item setting">
          <a href="#" class="layui-icon layui-icon-more-vertical"></a>
        </li>
      </ul>
    </div>
    <!-- 侧 边 区 域 -->
    <div class="layui-side layui-bg-black">
      <!-- 菜 单 顶 部 -->
      <div class="layui-logo">
        <!-- 图 标 -->
        <img class="logo" />
        <!-- 标 题 -->
        <span class="title"></span>
      </div>
      <!-- 菜 单 内 容 -->
      <div class="layui-side-scroll">
        <div id="sideMenu"></div>
      </div>
    </div>
    <!-- 视 图 页 面 -->
    <div class="layui-body">
      <!-- 内 容 页 面 -->
      <div id="content"></div>
    </div>
    <!-- 页脚 -->
    <div class="layui-footer layui-text">
      <span class="left"> Released under the MIT license. </span>
      <span class="center"></span>
      <span class="right"> Copyright © 2021-2022 pearadmin.com </span>
    </div>
    <!-- 遮 盖 层 -->
    <div class="pear-cover"></div>
    <!-- 加 载 动 画 -->
    <div class="loader-main">
      <!-- 动 画 对 象 -->
      <div class="loader"></div>
    </div>
  </div>
  <!-- 移 动 端 便 捷 操 作 -->
  <div class="pear-collapsed-pe collapse">
    <a href="#" class="layui-icon layui-icon-shrink-right"></a>
  </div>
  <!-- 依 赖 脚 本 -->
  <script src="component/layui/layui.js"></script>
  <script src="component/pear/pear.js"></script>
  <script src="utils/jquery-3.6.0.min.js"></script>
  <script src="utils/jquery.cookie.js"></script>
  <script src="config/config.js"></script>
  <script type="text/javascript" src="utils/vue.min.js"></script>
  <script type="text/javascript" src="component/elementUI/index.js"></script>
  <script src="utils/utils.js"></script>
  <!-- 框 架 初 始 化 -->
  <script>
    layui.use(["admin", "jquery", "popup", "drawer"], function () {
      var $ = layui.jquery;
      var admin = layui.admin;
      var popup = layui.popup;
      var convert = layui.convert;
      try {
        console.log($.cookie("token"));
        let User_Number = sessionStorage.getItem("User_Number");
        let Enterprise_Info_SerialNumber = sessionStorage.getItem(
          "Enterprise_Info_SerialNumber"
        );
        let System_SerialNumber = sessionStorage.getItem(
          "System_SerialNumber"
        );
        $.cookie('enterprise', Enterprise_Info_SerialNumber);
        // setCookie('enterprise',Enterprise_Info_SerialNumber)
        console.log(User_Number);
        console.log(Enterprise_Info_SerialNumber);
        console.log(System_SerialNumber);
        $.ajax({
          headers: {
            AccessToken: $.cookie("token"), //会将数据转换为query string
          },
          // url: "http://192.168.10.92:8087/getConfigForHtmlAction",
          url: "https://service.kdddy.cn/donghuiForRequest/getConfigForHtmlAction",
          type: "get",
          data: {
            token: $.cookie("token"),
            User_Number: User_Number,
            Enterprise_Info_SerialNumber: Enterprise_Info_SerialNumber,
            system: System_SerialNumber,
          },
          dataType: "json",
          async: false,
          // complete: function (xhr, status) {
          //   // 检查 Token 是否过期
          //   if (xhr.statusCode === 302) {
          //     // 清除本地存储的 Token
          //     sessionStorage.removeItem("token");
          //     // 从响应头中获取重定向信息
          //     const redirectUrl = xhr.header.contentpath;
          //     if (redirectUrl) {
          //       // 如果有重定向信息，跳转到指定页面
          //       // window.location.href = redirectUrl;
          //       window.location.href =
          //         "https://www.kdddy.cn/manage/login.html";
          //     }
          //   }
          // },
          complete: function (XMLHttpRequest) {
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href =
                XMLHttpRequest.getResponseHeader("Contentpath");
            }
          },
          success: function (result) {
            console.log(result);
            console.log(result.PageConfiguration);
            sessionStorage.setItem("RoleArr", JSON.stringify(result.Role));
            admin.setConfigType("JSONString");
            admin.setConfigPath(result.PageConfiguration);
          },
        });
      } catch (error) {
        window.parent.document.location.href = "login.html";
      }

      // admin.setConfigType("yml");
      // admin.setConfigPath("config/pear.config.yml");
      admin.render();
      // 登出逻辑
      admin.logout(function () {
        popup.success("注销成功", function () {
          location.href = "login.html";
        });
        // 注销逻辑 返回 true / false
        return true;
      });
      // 消息点击回调
      // admin.message(function (id, title, context, form) { });
    });
    new Vue({
      el: '#app',
      data() {
        return {

        }
      },
      methods: {
        handleCance() {
          const that = this;
          this.$confirm('此操作将注销该账户, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            $.ajax({
              url: BASE_URL2 + '/generalBusiness/generalQueryByTableNameWithOriginal',
              type: 'POST',
              data: {
                Data: "enterprise_info",
                Condition: "Enterprise_Info_SerialNumber='" + $.cookie("enterprise") + "'",
              },
              success: function (data) {
                data[0].Row_Status = '77';
                $.ajax({
                  headers: requestHeaders(),
                  type: "POST",
                  url: `${BASE_URL2}/generalBusiness/generalSave`,
                  data: {
                    Data: JSON.stringify({
                      Modify: {
                        enterprise_info: data
                      }
                    })
                  },
                  success: function (Result) {
                    that.$message({
                      type: 'success',
                      message: '企业已注销!'
                    });
                    location.href = "login.html";
                  },
                  complete: function (XMLHttpRequest) {
                    //   requestPretreatment(XMLHttpRequest);
                  },
                  dataType: "json",
                });
              },
            })
          }).catch(() => { });
        }
      }
    })
  </script>
</body>

</html>